<template>
    <div>
     <h1>房号信息录入</h1>
     <table class="table">
        <thead>
            <tr>
                <td>房号</td>
                <td>
                   <input type="text" v-model="data.roomId">
                </td>
            </tr>
             <tr>
                <td>门店名称</td>
                <td>
                     <select v-model="data.memberId">
                        <option value="0">请选择</option>
                        <option v-for="b in qwert" :value="b.memberId">{{ b.name }}</option>
                     </select>

                </td>
            </tr>
             <tr>
                <td>房型名称</td>
                <td>
                     <select v-model="data.roomTypeId">
                        <option value="0">请选择</option>
                        <option v-for="c in qwery" :value="c.roomTypeId">{{ c.name }}</option>
                     </select>
                </td>
            </tr>
             <tr>
                <td>排序</td>
                <td>
                     <input type="text" v-model="data.paixu">
                </td>
            </tr>
             <tr>
                <td>门店状态</td>
                <td>
                    <input type="radio" name="start" id="" v-model="data.start" value="1">上架
                     <input type="radio" name="start" id="" v-model="data.start" value="2">下架
                </td>
            </tr>
             <tr>
              
                <td colspan="2">
                    <input type="button" value="添加" @click="Add">
                </td>
            </tr>
        </thead>
     </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from "vue"
import axios from "axios";
import { useRouter } from "vue-router";
const router=useRouter()
onMounted(()=>{
    Xiala()
    Xialak();
})
const data=ref({
     "isDelete": true,
  "createId": 0,
  "createTime": "2025-06-16T10:02:37.811Z",
  "updateId": 0,
  "updateTime": "2025-06-16T10:02:37.811Z",
  "deleteId": 0,
  "deleteTime": "2025-06-16T10:02:37.811Z",
  "id": 0,
  "roomId": 0,
  "memberId": 0,
  "roomTypeId": 0,
  "start": 0,
  "paixu": 0
})
const Add=()=>{
    axios.post("https://localhost:7162/api/RoomModel/AddMember",data.value).then(res=>{
     
        if(res.data>0){
            alert('添加成功');
            router.push("/ShowView");
        }
        else{
            alert('添加失败,房号唯一，房号重复');
        }
    })
}
const qwert=ref([{
      "memberId": 3,
    "name": "顺丰大酒店",
}])
const Xiala=()=>{
    axios.get("https://localhost:7162/api/RoomModel/Xiala").then(res=>{
        qwert.value=res.data
    })
}
const qwery=ref([{
     "roomTypeId": 1,
    "name": "单人房"
}])
const Xialak=()=>{
    axios.get("https://localhost:7162/api/RoomModel/Xialak").then(res=>{
        qwery.value=res.data
    })
}
</script>

<style scoped>

</style>